/*
package com.ww.springboot.pdf;

import cn.hutool.http.HttpRequest;
import com.ww.springboot.boot.utils.Func;
import net.sourceforge.tess4j.Tesseract;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class TesseractTest {

    public static void main(String[] args) {

        String ss = "RLBN00008071";

        List<String> collect = Func.toStrList(ss);

        Tesseract tesseract = new Tesseract();
        //tesseract.setLanguage("eng"); // 默认就是eng，你可以选择其他lang
        tesseract.setDatapath("C:\\Program Files\\tessdata2\\");

        collect.forEach(s -> {

            try {
                String url = "https://bullfrog-master.oss-cn-shenzhen.aliyuncs.com/delivery_label/" + s + ".pdf";

                byte[] bytes = HttpRequest.get(url).execute().bodyBytes();

                BufferedImage image = ImageIO.read(new ByteArrayInputStream(PdfUtil.pdfToImageFile(bytes)));
                String ocr = tesseract.doOCR(image);
                System.out.println(ocr);
                String[] split = ocr.split("\n");
                List<String> collect2 = Arrays.stream(split).map(sss -> sss = sss.replace(" ", "")).collect(Collectors.toList());
                collect2 = collect2.stream().filter(ssss -> ssss.contains(s)).collect(Collectors.toList());
                System.out.println(collect2);
                if (collect2.size() == 0) {
                    System.out.println("异常订单:" + s);
                }
            } catch (Exception e) {
                System.out.println("异常：" + s);
                e.printStackTrace();
            }
        });
    }

}*/
